from datetime import date, timedelta
from random import randint
import time


def bulid_person_brithday(name_list):
    name_brithday = {}.fromkeys(name_list)
    for key in name_brithday:
        year = randint(1990, 1999)
        month = randint(1, 12)
        day = randint(1, 30)
        name_brithday[key] = date(year, month, day)
    return name_brithday


def person_brithday_summer(name_brithday):
    person_list = []
    for key in name_brithday:
        if name_brithday[key].month >= 6 and name_brithday[key].month <= 8:
            person_list.append(key)
    return person_list


def max_person_brithday(name_brithday):
    list_person_brithday = list(name_brithday.values())
    list_person_brithday.sort()
    _max_person_brithday = list_person_brithday[0]
    for key in name_brithday:
        if name_brithday[key] == list_person_brithday[0]:
            print("{}的生日最早,Ta的生日是{}".format(key, list_person_brithday[0]))
    return _max_person_brithday


def min_person_brithday(name_brithday):
    list_person_brithday = list(name_brithday.values())
    list_person_brithday.sort()
    _min_person_brithday = list_person_brithday[len(list_person_brithday)-1]
    for key in name_brithday:
        if name_brithday[key] == list_person_brithday[9]:
            print("{}的生日最晚,Ta的生日是{}".format(key, list_person_brithday[9]))
    return _min_person_brithday


if __name__ == '__main__':
    list_name =["李一", "李二", "李三", "李四", "李五", "李六", "李七", "李八", "李九", "李十"]
    name_brithday_list = bulid_person_brithday(list_name)
    print(name_brithday_list)
    summer_person_brithday = person_brithday_summer(name_brithday_list)
    print("生日在夏天的有{}".format(summer_person_brithday))
    max_person = max_person_brithday(name_brithday_list)
    min_person = min_person_brithday(name_brithday_list)
    cha = min_person - max_person
    print("最大的比最小的大{}天".format(cha))





